﻿
if col_length('ERPStoreOffersEntitySelectedDetailExtension', 'FixedShippingPrice') is null
Begin
	alter table dbo.ERPStoreOffersEntitySelectedDetailExtension add FixedShippingPrice bigint null
end
Go

alter view dbo.ERPStoreOffersOfferedProduct
As
Select 
EntitySelectionDetail.Id as Id
, InternalEntityId as ProductId
, EntitySelectionDetail.EntitySelectionId as SelectionId
, ERPStoreOffersEntitySelectedDetailExtension.SalePrice
, ERPStoreOffersEntitySelectedDetailExtension.StrikedPrice
, ERPStoreOffersEntitySelectedDetailExtension.Discount
, ERPStoreOffersEntitySelectedDetailExtension.SaleFactor
, ERPStoreOffersEntitySelectedDetailExtension.FixedShippingPrice
From EntitySelection
		join EntitySelectionDetail on EntitySelection.Id = EntitySelectionDetail.EntitySelectionId
		left join ERPStoreOffersEntitySelectedDetailExtension on EntitySelectionDetail.Id = ERPStoreOffersEntitySelectedDetailExtension.ERPStoreOffersEntitySelectedDetailExtensionId
where EntitySelection.EntityNameBase = 'Product'
Go
